/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Microsoft
 * Date: 2022-11-20
 * Time: 15:01
 */
class Student {
    public String name = "123";
    private int age;
    private static int size;

    public Student() {
        System.out.println("不带参数的构造方法");
    }

    static {
        System.out.println("静态的代码块");
    }

    {
        name = "caocao";
        System.out.println("非静态代码块/实例代码块/构造代码块 -> 一般用来初始化非静态的数据成员");
    }

    public static int getSize() {
        return size;
    }

    public static void setSize(int size) {
        Student.size = size;
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
        System.out.println("带有两个参数的构造方法");
    }




    public Student(String name, int age, int si) {
        this.name = name;
        this.age = age;
        Student.size = si;
    }
    public void doClass() {
        System.out.println(name + "上课");
        func();
    }

    public static void func() {
        Student student = new Student();
        student.doClass();
        Student.func2();
    }
    public static void func2() {
        System.out.println("staticFunc()");
    }


}

public class Test2 {
    public static void main(String[] args) {
        Student student = new Student("123",123);
        System.out.println(student);
    }
}





//    public static void main(String[] args) {
//        //普通代码块
//        {
//            int a = 10;
//        }
//    }

//    public static void main(String[] args) {
//        Student student1 = new Student("gaobo",10);
//        //可以通过对象进行调用静态成员方法，但是不推荐
//        student1.func();
//        //建议通过类进行调用静态成员方法
//        Student.func();
//    }

//    public static void main1(String[] args) {
//        Student student1 = new Student("gaobo",10);
//        //静态成员变量可以直接通过类名进行访问
//        System.out.println(Student.classRoom);
//        //静态成员变量也可以通过对象进行访问，但是编译器并没有进行提示，并且给予警告
//        System.out.println(student1.classRoom);
//    }
